home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 62
/
062.d81
/
stats toolbox
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
26KB
|
760 lines
100 rem stats toolbox
102 goto116
104 :
106 getq$:ifq$=""then106
108 return
110 :
112 printtab((40-len(a$))/2);t$;a$:return
114 :
116 sa=679:forj=satosa+35:readb:poke j,b:next
118 data 32,253,174,32,158,183,138,56,201,40,144,5,162,14,76,139,227,72
120 data 32,253,174,32,158,183,138,56,201,25,176,238,104,168,24,76,240,255
122 :
123 qz=0:qw=1
124 poke 53280,.:poke 53281,.:poke 646,1:poke 53272,23:fl=0:dim cx(101)
126 def fn d4(x)=int(10000*x+.05)/10000
128 def fn d1(x)=int(10*x+.05)/10:def fn frc(x)= x-int(x)
129 def fn cn(x)=20-len(mu$(x))/2
130 so$=" ":sr$=""+so$
132 dim mu$(6):mu$(2)=" [193]verage and [211]td.[196]ev ":mu$(3)=" [212]-test "
134 mu$(1)=" [195]hi [211]quare ":mu$(4)=" [210]andom [206]umbers "
135 mu$(6)=" [209]uit ":mu$(5)=" [205]edian "
136 :
138 rn$=chr$(18):rf$=chr$(146)
140 print"[147] [162][162][162][162][162][162][162][162][162][162][162][162][155] ";
142 print" [161][155] [161][155][146] ";
144 print" [172][162][162][162][162][162][162][162][162][162][162][162][172][162][187][162][162][162][162][162][162][162][162]";
146 print"[162][162][162][146][161][155] [161][155] [161][155] [161]";
148 print"[155][146] [161][155] [188][146][162][162][162][162][162][162][162]";
150 print"[162][162][162][162][188][146][162][190][146][162][162][162][162][162][162][162][162][162][162][162][161][155] [161][155]";
152 print" [161] [161][155][146] [161][155] ";
154 print" [161][155] [188][146][162][190][155][146] ";
156 print"[161][155] [161][155] ";
158 print" [161][155] [161][155] ";
160 print" [161][155] [188][146][162][162][162][162][162][162][162][162][162][162][162][162][162]";
162 print"[162][162][162][162][162][162][162][162][162][162][162][162][161][155] "
164 print"[145][211]tatistician's [212]oolbox"
166 print" [208]ress any key "
168 gosub1574:poke646,1:gosub106:goto186
170 :
172 print"";
174 forx=1to12:printso$:next:return
176 :
178 print"[147]":gosub180:fl=0:t$=rn$:return
180 syssa,0,12
182 forx=1to12:printsr$:next:syssa,0,13:return
184 :
186 print"[147] [207]ften called 'number crunching', ";
188 print"statistics offers us a lot of tools to ";
190 print"give MEANING to what is otherwise a ";
192 print"jumble of numbers. We say Joe Baseball ";
194 print"is batting 500 this season. We then ";
196 print"know he is hitting one for every one he ";
198 print"misses. We can also see that he has the";
200 print"edge on Matty Homeplate who is batting ";
202 print"470. The batting average is a crunched ";
204 print"number, based on a long list of single ";
206 print"swings. [215]e can [213][211][197] the batting average ";
208 print"where the list of single swing results ";
210 print"would simply confuse us. ";
212 print" ";
214 print" This toolbox is an introduction to ";
216 print"some other statistical tools that give ";
218 print"a single number to describe a lot of ";
220 print"numbers. You'll be able to view a ";
222 print"tutorial as well as try using the tools ";
224 print"for yourself. ";
226 print" [208]ress any key "
228 gosub106
230 t$=rf$:print"[147] [212]he [212]oolbox"
232 print" ==========="
234 for x=1 to 6:print tab(fn cn(x))mu$(x):print:next
236 print"[195][210][211][210] [213][208]/[196][206] to select / [210][197][212][213][210][206] to choose"
237 print" [198]1 - background color [198]7 - text color":x=1:goto240
238 print"":goto242
240 print""
242 printtab(fn cn(x))"";mu$(x)
244 getqf$:ifqf$=""then244
245 ifqf$="[133]"orqf$="[136]"then251
246 ifqf$=chr$(13)then264
248 ifqf$=""thenx=x+1:goto255
249 ifqf$="[145]"thenx=x-1:goto254
250 goto244
251 ifqf$="[133]"thenqz=qz+1:qz=qzand15:ifqz=qwthenqz=qz+1:qz=qzand15
252 ifqf$="[136]"thenqw=qw+1:qw=qwand15:ifqw=qzthenqw=qw+1:qw=qwand15
253 poke53281,qz:poke53280,qz:poke646,qw:goto230
254 print"[145]"tab(fn cn(x+1))mu$(x+1)"[145][145][145][145]":goto256
255 print"[145]"tab(fn cn(x-1))mu$(x-1)
256 ifx>6thenx=1:goto240
257 ifx<1thenx=6:goto238
258 print""tab(fn cn(x))"";mu$(x)
260 goto244
262 :
264 onxgoto266,828,960,1164,1296,1564
266 t$=rf$:goto284
268 sys sa,0,3
270 print" [176][192][192][192][192][192][192][178][192][192][192][192][192][192][174]"
272 print" [221] [221] [221]"
274 print" [171][192][192][192][192][192][192][219][192][192][192][192][192][192][219][192][192][192][192][192][192]"
276 print" [221] [221] [221]"
278 print" [173][192][192][192][192][192][192][219][192][192][192][192][192][192][219][192][192][192][192][192][192]"
280 print" [221] [221]"
282 return
284 print"[147] [212]he [195]hi-square [212]est [146]"
286 a$="[212]he basic idea behind the [195]hi":gosub112
288 a$="[211]quare is to find out if a set of":gosub112
290 a$="numbers just happened that way by":gosub112
292 a$="'chance' - or if there was some":gosub112
294 a$="social or economic factor which":gosub112
296 a$="might have influenced the outcome":gosub112
298 a$="to some extent.":gosub112
300 a$=" [212]-[212]utorial [196]-[196]ata [197]ntry [205]-[205]enu [146]":fl=1:da=0:gosub1536
302 on ch goto304,230,610
304 print"[147]":gosub180:fl=0:t$=rn$
306 a$="[200]ere we see the typical 2 by 2":gosub112
308 a$="[195]hi-square grid. [212]his one displays":gosub112
310 a$="the results of a (fictitious) survey":gosub112
312 a$="where people were asked whether they":gosub112
314 a$="preferred using a [195]ommodore 64 or an":gosub112
316 a$="[201][194][205]-[208][195]. [193]lso, their residence was":gosub112
318 a$="categorized as [197]ast or [215]est of the":gosub112
320 a$="[205]ississippi [210]iver.":gosub112
322 gosub268
324 sys sa,4,4:print"[197]ast":sys sa,4,6:print"[215]est"
326 sys sa,11,4:print"344":sys sa,17,4:print"451":sys sa,11,6:print"482"
328 sys sa,17,6:print"499":sys sa,10,2:print"[195]-64":sys sa,17,2:print"[201][194][205]"
330 gosub1536:on ch goto332,230
332 gosub180
334 a$="[212]he survey results are set up in":gosub112
336 a$="a grid of 2 rows and 2 columns seen":gosub112
338 a$="here. [201]t looks like a small":gosub112
340 a$="spreadsheet. [201]f we had included [193]pple":gosub112
342 a$="computers in our survey we would":gosub112
344 a$="have a grid of 2 rows by 3 columns.":gosub112
346 a$="[215]e put in the row and":gosub112
348 a$="column totals because they are":gosub112
350 a$="needed to do the [195]hi-square.":gosub112
352 sys sa,23,4:print"795":sys sa,23,6:print"981":sys sa,11,8:print"826"
354 sys sa,17,8:print"950":sys sa,23,8:print "1776":gosub1536
356 on ch goto358,230
358 gosub180
360 a$="[212]he [195]hi-square test looks at the":gosub112
362 a$="[193][195][212][213][193][204] survey results we see here":gosub112
364 a$="and compares them to what would":gosub112
366 a$="be [197][216][208][197][195][212][197][196] by 'chance.'":gosub112
368 a$="[215]e want to know if people in one area":gosub112
370 a$="really prefer one computer over":gosub112
372 a$="another or these results just":gosub112
374 a$="happened by chance.":gosub112:gosub1536:onchgoto376,230
376 gosub180
378 a$="[215]e start by finding the corresponding":gosub112
380 a$="'expected' value for [197][193][195][200] of the 4":gosub112
382 a$="actual values shown. [212]he expected":gosub112
384 a$="value is found by [205][213][204][212][201][208][204][217][201][206][199] the":gosub112
386 a$="corresponding row and column totals":gosub112
388 a$="for each value then [196][201][214][201][196][201][206][199] the":gosub112
390 a$="product by the grand total.":gosub112
392 a$="826 times 795 divided by 1776 is":gosub112
394 a$="369.8 - the expected value for 344.":gosub112
396 sys sa,10,4:print" 344 [146]"
398 sys sa,12,10:print"^":sys sa,29,4:print"_":sys